package org.simple.wechat.demo.config;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import org.simple.wechat.demo.dto.Week;

import java.io.IOException;

/***
 * @author gaoqijin
 * @date 2020-11-18
 * @Description
 */
public class WeekSerialize extends JsonSerializer<Week> {
    @Override
    public void serialize(Week week, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
        jsonGenerator.writeStartObject();
        jsonGenerator.writeFieldName("code");
        jsonGenerator.writeString(String.valueOf(week.getCode()));
        jsonGenerator.writeFieldName("desc");
        jsonGenerator.writeString(week.getDesc());
        jsonGenerator.writeEndObject();
    }
}
